package com.qf.commons.event.mq.standrad;

import com.qf.commons.event.entity.QphoneMessage;
import com.qf.commons.event.mq.kafka.handler.KafkaMqProduceStandard;
import com.qf.commons.event.mq.rabbitmq.handler.RabbitMQProduceStandardHandler;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * kafka、rabbitmq底层实现的一个门面对象
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
public class CoreMqProduceStandard implements MqProduceStandard{

    @Autowired
    private RabbitMQProduceStandardHandler rabbitMQProduceStandardHandler;

    @Autowired
    private KafkaMqProduceStandard kafkaMqProduceStandard;

    @Override
    public void sendMessage(QphoneMessage qphoneMessage) {
        if (qphoneMessage.getDelayMs() == -1) {
            //迅捷消息
            kafkaMqProduceStandard.sendMessage(qphoneMessage);
        } else {
            //延迟消息
            rabbitMQProduceStandardHandler.sendMessage(qphoneMessage);
        }
    }
}
